package ch.unisi.inf.java.project.riskbami.model;

import java.util.ArrayList;

/**
 * The test class CountryTest.
 *
 * @author minellir@lu.unisi.ch
 * @author babazadm@lu.unisi.ch
 */
public class CountryTest extends junit.framework.TestCase
{
   
    public final void testConstructor()
    {
        final Country country1 = new Country("Swiss");
        assertEquals("Swiss", country1.getName());
        assertEquals(new ArrayList<Country>(), country1.getNearbyCountries());
    }
    
    public final void testNearbyCountries()
    {
        final Country country1 = new Country("Swiss");
        java.util.ArrayList<Country> testArray = new java.util.ArrayList<Country>();
        testArray.add(country1);
        final Country country2 = new Country("Swiss");
        country2.setNearby(testArray);
        assertEquals(testArray, country2.getNearbyCountries());
    }
    
    public final void testAddRemoveArmies()
    {
        final Country country1 = new Country("Egypt");
        final int armiesToAdd = 12;
        country1.addArmies(armiesToAdd);
        assertEquals(armiesToAdd, country1.getNumberOfArmies());
        country1.removeArmies(armiesToAdd);
        assertEquals(0, country1.getNumberOfArmies());
    }

	public final void testAttackCountry()
	{
		final Country country1 = new Country("Swiss");
		final Country country2 = new Country("Italy");
		country1.addArmies(10);
		country2.addArmies(10);
		final int totalArmies = country1.getNumberOfArmies() + country2.getNumberOfArmies();
		country1.attackCountry(country2);
		assertEquals(20, totalArmies);
		assertTrue(totalArmies >= country1.getNumberOfArmies() + country2.getNumberOfArmies());
	}
}


 